﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class DepartmentW
    {
        string deptID;
        string deptName;
        int contactPersonID;
        int phoneNo;
        int faxNo;
        int deptHeadID;
        int collectionPointID;
        int representativeID;
        int actingManagerID;

        [DataMember]
        public string DeptID
        {
            get { return deptID; }
            set { deptID = value; }
        }

        [DataMember]
        public string DeptName
        {
            get { return deptName; }
            set { deptName = value; }
        }

        [DataMember]
        public int ContactPersonID
        {
            get { return contactPersonID; }
            set { contactPersonID = value; }
        }

        [DataMember]
        public int PhoneNo
        {
            get { return phoneNo; }
            set { phoneNo = value; }
        }

        [DataMember]
        public int FaxNo
        {
            get { return faxNo; }
            set { faxNo = value; }
        }

        [DataMember]
        public int DeptHeadID
        {
            get { return deptHeadID; }
            set { deptHeadID = value; }
        }

        [DataMember]
        public int CollectionPointID
        {
            get { return collectionPointID; }
            set { collectionPointID = value; }
        }

        [DataMember]
        public int RepresentativeID
        {
            get { return representativeID; }
            set { representativeID = value; }
        }

        [DataMember]
        public int ActingManagerID
        {
            get { return actingManagerID; }
            set { actingManagerID = value; }
        }

        public static DepartmentW convert(Department department)
        {
            DepartmentW u = new DepartmentW();

            u.DeptID = department.DeptID;
            u.DeptName = department.DeptName;
            u.ContactPersonID = department.ContactPersonID.GetValueOrDefault();
            u.PhoneNo = department.PhoneNo.GetValueOrDefault();
            u.FaxNo = department.FaxNo.GetValueOrDefault();
            u.DeptHeadID = department.DeptHeadID.GetValueOrDefault();
            u.CollectionPointID = department.CollectionPointID.GetValueOrDefault();
            u.RepresentativeID = department.RepresentativeID.GetValueOrDefault();
            u.ActingManagerID = department.ActingManagerID.GetValueOrDefault();

            return u;
        }

        public static List<DepartmentW> convertList(List<Department> list)
        {
            List<DepartmentW> listW = new List<DepartmentW>();

            foreach (Department x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }
    }
}